/**

 * Created by dell on 2017/5/11.

 */

import java.util.Random;
import java.util.Scanner;
import java.text.NumberFormat;

public class NumberCounter {
    public static void main(String args[]) {
        NumberFormat nf = NumberFormat.getPercentInstance();
        integer num1, num2;
        RationalNumber N1, N2 = null, N3 = null;
        String Q = null, A;
        int trues = 0;
        Random generator = new Random();
        int num, answer;
        Scanner scan = new Scanner(System.in);

        System.out.println("题目数量： ");
        int num4 = scan.nextInt();
        int num6 = generator.nextInt(1);
        /*if (num6 == 0) {
            for (int i = 0; i < num4; i++) {
                int num5 = generator.nextInt(3);
                num1 = integer.obj();
                num2 = integer.obj();
                switch (num5) {
                    case 0:
                        num = num1.add(num2);
                        System.out.println(num1.getNum() + "+" + num2.getNum() + "=");
                        answer = scan.nextInt();
                        String question = (num1.getNum() + "+" + num2.getNum() + "=");
                        if (answer == num)
                            trues++;
                        else
                            System.out.println("正确答案： " + num);
                        break;
                    case 1:
                        num = num1.reduce(num2);
                        System.out.println(num1.getNum() + "-" + num2.getNum() + "=");
                        answer = scan.nextInt();
                        question = (num1.getNum() + "-" + num2.getNum() + "=");
                        if (answer == num)
                            trues++;
                        else
                            System.out.println("正确答案： " + num);
                        break;
                    case 2:
                        num = num1.ride(num2);
                        System.out.println(num1.getNum() + "*" + num2.getNum() + "=");
                        answer = scan.nextInt();
                        question = (num1.getNum() + "*" + num2.getNum() + "=");
                        if (answer == num)
                            trues++;
                        else
                            System.out.println("正确答案： " + num);
                    case 3:
                        num = num1.excepet(num2);
                        System.out.println(num1.getNum() + "/" + num2.getNum() + "=");
                        answer = scan.nextInt();
                        question = (num1.getNum() + "/" + num2.getNum() + "=");
                        if (answer == num)
                            trues++;
                        else
                            System.out.println("正确答案： " + num);
                        break;
                }
            }
        } else {  */
            int num5 = generator.nextInt(3);
            switch (num5) {
                case 0:
                    N1 = N2.add(N3);
                    Q = N1.toString();
                    System.out.print("(" + N2.toString() + ")" + " + " + "(" + N3.toString() + ")" + "=");
                    A = scan.next();
                    if (A == Q)
                        trues++;
                    else
                        System.out.println("正确答案： " + Q);
                    break;
                case 1:
                    N1 = N2.subtract(N3);
                    Q = N1.toString();
                    System.out.print("(" + N2.toString() + ")" + " - " + "(" + N3.toString() + ")" + "=");
                    A = scan.next();
                    if (A == Q)
                        trues++;
                    else
                        System.out.println("正确答案： " + Q);
                    break;
                case 2:
                    N1 = N2.multiply(N3);
                    Q = N1.toString();
                    System.out.print("(" + N2.toString() + ")" + " * " + "(" + N3.toString() + ")" + "=");
                    A = scan.next();
                    if (A == Q)
                        trues++;
                    else
                        System.out.println("正确答案： " + Q);
                    break;
                case 3:
                    N1 = N2.divide(N3);
                    Q = N1.toString();
                    System.out.print("(" + N2.toString() + ")" + " / " + "(" + N3.toString() + ")" + "=");
                    A = scan.next();
                    if (A == Q)
                        trues++;
                    else
                        System.out.println("正确答案： " + Q);
                    break;
            }
            System.out.println("答对数： " + trues);
            NumberFormat fmt = NumberFormat.getPercentInstance();
            double rate = (double) trues / num4;
            System.out.println("正确率： " + fmt.format(rate));
        }
    }
